package org.the.gsdo.server;

import java.util.logging.Level;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Profile;
import org.the.gsdo.shared.SendTextToServer;

import com.gwtplatform.dispatch.server.actionvalidator.ActionValidator;
import com.gwtplatform.dispatch.server.spring.HandlerModule;
import com.gwtplatform.dispatch.server.spring.actionvalidator.DefaultActionValidator;
import com.gwtplatform.dispatch.server.spring.configuration.DefaultModule;

@Configuration
@Import(DefaultModule.class)
@ComponentScan(basePackages = {"com.gwtplatform.dispatch.server.spring"})
@Profile("main")
public class GwtServiceConfiguration extends HandlerModule {

	public GwtServiceConfiguration() {}

	@Bean(name="logger")
	public com.gwtplatform.dispatch.server.spring.LoggerFactoryBean getLogger() {
		java.util.logging.Logger utilLogger = java.util.logging.Logger.getAnonymousLogger();
		utilLogger.setLevel(Level.FINEST);
		return new com.gwtplatform.dispatch.server.spring.LoggerFactoryBean(utilLogger);
	}

	@Bean
	public SendTextToServerHandler getSendTextToServerHandler() {
		return new SendTextToServerHandler();
	}

	@Bean
	public ActionValidator getDefaultActionValidator() {
		return new DefaultActionValidator();
	}

	@Override
	protected void configureHandlers() {
		bindHandler(SendTextToServer.class, SendTextToServerHandler.class);
	}
}

